<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta property="og:type" content="website">
<meta property="og:title" content="Frone&#39;s Blog">
<meta property="og:url" content="http://yoursite.com/page/2/index.html">
<meta property="og:site_name" content="Frone&#39;s Blog">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Frone&#39;s Blog">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/page/2/"/>





  <title>Frone's Blog</title><!-- hexo-inject:begin --><!-- hexo-inject:end -->
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <!-- hexo-inject:begin --><!-- hexo-inject:end --><div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Frone's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术小窝</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/07/27/python使用国内源/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Frone Xie">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Frone's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/07/27/python使用国内源/" itemprop="url">pip使用国内源</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-07-27T11:21:51+08:00">
                2018-07-27
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/算法/" itemprop="url" rel="index">
                    <span itemprop="name">算法</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2018/07/27/python使用国内源/" class="leancloud_visitors" data-flag-title="pip使用国内源">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="安装-Pulp-等包时遇到问题"><a href="#安装-Pulp-等包时遇到问题" class="headerlink" title="安装 Pulp 等包时遇到问题"></a>安装 Pulp 等包时遇到问题</h3><p>在安装一个不是很常用的python库时 遇到了长时间无法下载安装的问题，之前也有配置过国内的pip 源所以在这整理下</p>
<h3 id="直接修改国内源为默认"><a href="#直接修改国内源为默认" class="headerlink" title="直接修改国内源为默认"></a>直接修改国内源为默认</h3><p>创建或修改配置文件</p>
<p>linux的文件在~/.pip/pip.conf，</p>
<p>windows在%HOMEPATH%\pip\pip.ini）</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">[global]</span><br><span class="line">index-url = http://pypi.douban.com/simple</span><br><span class="line">[install]</span><br><span class="line">trusted-host=pypi.douban.com</span><br></pre></td></tr></table></figure>
<p>除了豆瓣还有其他的国内源：</p>
<ul>
<li>阿里云 <a href="http://mirrors.aliyun.com/pypi/simple/" target="_blank" rel="noopener">http://mirrors.aliyun.com/pypi/simple/</a></li>
<li>中国科技大学 <a href="https://pypi.mirrors.ustc.edu.cn/simple/" target="_blank" rel="noopener">https://pypi.mirrors.ustc.edu.cn/simple/</a></li>
<li>豆瓣(douban) <a href="http://pypi.douban.com/simple/" target="_blank" rel="noopener">http://pypi.douban.com/simple/</a></li>
<li>清华大学 <a href="https://pypi.tuna.tsinghua.edu.cn/simple/" target="_blank" rel="noopener">https://pypi.tuna.tsinghua.edu.cn/simple/</a></li>
<li>中国科学技术大学 <a href="http://pypi.mirrors.ustc.edu.cn/simple/" target="_blank" rel="noopener">http://pypi.mirrors.ustc.edu.cn/simple/</a></li>
</ul>
<h3 id="其他"><a href="#其他" class="headerlink" title="其他"></a>其他</h3><p>此外在此mark一下 Pulp， 处理线性规划问题</p>
<ol>
<li><a href="https://pythonhosted.org/PuLP/index.html" target="_blank" rel="noopener">文档主页</a></li>
<li><a href="https://pythonhosted.org/PuLP/CaseStudies/a_blending_problem.html" target="_blank" rel="noopener">案例</a></li>
</ol>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/07/16/如何在hexo中支持Mathjax/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Frone Xie">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Frone's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/07/16/如何在hexo中支持Mathjax/" itemprop="url">如何在hexo中支持Mathjax</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-07-16T18:11:51+08:00">
                2018-07-16
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Hexo/" itemprop="url" rel="index">
                    <span itemprop="name">Hexo</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2018/07/16/如何在hexo中支持Mathjax/" class="leancloud_visitors" data-flag-title="如何在hexo中支持Mathjax">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="第一步：-使用Kramed代替-Marked"><a href="#第一步：-使用Kramed代替-Marked" class="headerlink" title="第一步： 使用Kramed代替 Marked"></a>第一步： 使用Kramed代替 Marked</h3><p>hexo 默认的渲染引擎是 marked，但是 marked 不支持 mathjax。 kramed 是在 marked 的基础上进行修改。我们在工程目录下执行以下命令来安装 kramed.<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">npm uninstall hexo-renderer-marked --save</span><br><span class="line">npm install hexo-renderer-kramed --save</span><br></pre></td></tr></table></figure></p>
<p>然后，更改/node_modules/hexo-renderer-kramed/lib/renderer.js，更改<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">// Change inline math rule</span><br><span class="line">function formatText(text) &#123;</span><br><span class="line">    // Fit kramed&apos;s rule: $$ + \1 + $$</span><br><span class="line">    return text.replace(/`\$(.*?)\$`/g, &apos;$$$$$1$$$$&apos;);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>为<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">// Change inline math rule</span><br><span class="line">function formatText(text) &#123;</span><br><span class="line">    return text;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<h3 id="第二步-停止使用-hexo-math"><a href="#第二步-停止使用-hexo-math" class="headerlink" title="第二步: 停止使用 hexo-math"></a>第二步: 停止使用 hexo-math</h3><p>首先，如果你已经安装 hexo-math, 请卸载它,然后安装 hexo-renderer-mathjax 包<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">npm uninstall hexo-math --save</span><br><span class="line">npm install hexo-renderer-mathjax --save</span><br></pre></td></tr></table></figure></p>
<h3 id="第三步-更改默认转义规则"><a href="#第三步-更改默认转义规则" class="headerlink" title="第三步: 更改默认转义规则"></a>第三步: 更改默认转义规则</h3><p>因为 hexo 默认的转义规则会将一些字符进行转义，比如 _ 转为 <em>, 所以我们需要对默认的规则进行修改.<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vi node_modules/kramed/lib/rules/nline.js</span><br></pre></td></tr></table></figure></em></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">// 替换11行</span><br><span class="line">escape: /^\\([\\`*&#123;&#125;\[\]()#$+\-.!_&gt;])/,</span><br><span class="line">//修改为</span><br><span class="line">escape: /^\\([`*\[\]()# +\-.!_&gt;])/,</span><br><span class="line"></span><br><span class="line">//替换20行</span><br><span class="line">em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,</span><br><span class="line">//修改为</span><br><span class="line">em: /^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,</span><br></pre></td></tr></table></figure>
<h3 id="第四步-开启mathjax"><a href="#第四步-开启mathjax" class="headerlink" title="第四步: 开启mathjax"></a>第四步: 开启mathjax</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vi themes/next/_config.yml</span><br></pre></td></tr></table></figure>
<p>开启 mathjax功能<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">mathjax:</span><br><span class="line">  enable: true</span><br><span class="line">  perpage: false</span><br><span class="line">  cdn: //cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML</span><br></pre></td></tr></table></figure></p>
<p>并在博客中使用mathjax<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">---</span><br><span class="line">title: Testing Mathjax with Hexo</span><br><span class="line">category: Uncategorized</span><br><span class="line">date: 2017/05/03</span><br><span class="line">mathjax: true</span><br><span class="line">---</span><br></pre></td></tr></table></figure></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/07/16/jaro-winkler算法原理和应用/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Frone Xie">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Frone's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/07/16/jaro-winkler算法原理和应用/" itemprop="url">Jaro–Winkler算法原理和应用</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-07-16T16:21:51+08:00">
                2018-07-16
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/算法/" itemprop="url" rel="index">
                    <span itemprop="name">算法</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2018/07/16/jaro-winkler算法原理和应用/" class="leancloud_visitors" data-flag-title="Jaro–Winkler算法原理和应用">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>[TOC]</p>
<h3 id="算法简介"><a href="#算法简介" class="headerlink" title="算法简介"></a>算法简介</h3><p>The Jaro–Winkler distance (Winkler, 1990)是计算2个字符串之间相似度的一种算法。它是Jaro distance算法的变种。主要用于record linkage/数据连接（duplicate detection/重复记录）方面的领域，Jaro–Winkler distance最后得分越高说明相似度越大。Jaro–Winkler distance 是适合于串比如名字这样较短的字符之间计算相似度。0分表示没有任何相似度，1分则代表完全匹配。</p>
<h3 id="算法定义"><a href="#算法定义" class="headerlink" title="算法定义"></a>算法定义</h3><ol>
<li>The Jaro distance算法最后得分公式：<script type="math/tex; mode=display">d_j = \frac{1}{3}\left(\frac{m}{|s1|} + \frac{m}{|s2|} + \frac{m-t}{m} \right)</script>其中:   </li>
</ol>
<ul>
<li>s1、s2 是要比对的两个字符</li>
<li>$d_j$是最后得分</li>
<li>m是匹配的字符数</li>
<li>t  是换位的数目</li>
</ul>
<ol>
<li>Match Window(匹配窗口)计算公式<script type="math/tex; mode=display">MW=\left(\frac{MAX(|s1|,|s2|)}{2}\right) - 1</script>其中：</li>
</ol>
<ul>
<li>s1、s2 是要比对的两个字符</li>
<li>MW是匹配窗口值</li>
</ul>
<ol>
<li>上述公式解释</li>
</ol>
<ul>
<li>字符串s1与字符串s2在做匹配计算时，当两个字符的距离不大于公式二的最后结果(匹配窗口)即认为是匹配的。</li>
<li>当s1、s2中字符相匹配但是字符位置不一样时发生换位操作、而公式一中换位的数目t为不同顺序的匹配字符的数目的一半。比如:两个字符串CRATE和TRACE做匹配操作，字符串中仅有’R’ ‘A’ ‘E’三个字符是匹配的，即m=3。为什么’C’, ‘T’不算做是匹配的呢。因为虽然’C’, ‘T’都出现在两个字符串中，但是通过公式二得出匹配窗口值为 (5/2)-1=1.5。而两个字符串中’C’, ‘T’字符的距离均大于1.5。所以不算做匹配。因此t=0。在另一组字符串DwAyNE 与 DuANE 。匹配的字符D-A-N-E 在两个字符串中有相同的字符顺序，所以不需要进行换位操作，因此t=0,m=4。</li>
</ul>
<ol>
<li>Jaro–Winkler distance算法公式<br>Jaro-Winkler算法给予了起始部分就相同的字符串更高的分数，它定义了一个前缀范围p，对于要匹配的两个字符串，如果前缀部分有长度为L的部分字符串相同，则Jaro-Winkler Distance为:<script type="math/tex; mode=display">d_w = d_j + L * P(1 - d_J)</script>其中:   </li>
</ol>
<ul>
<li>$d_j$是Jaro distance最后得分</li>
<li>L是前缀部分匹配的长度</li>
<li>P是一个范围因子常量，用来调整前缀匹配的权值，但是P的值不能超过0.25，因为这样最后得分可能超过1分.Winkler的标准默认设置值P=0.1。</li>
</ul>
<h3 id="例子"><a href="#例子" class="headerlink" title="例子"></a>例子</h3><p>给出两个字符串 s1 MARTHA 和 s2 MARHTA、我们可以得出：</p>
<ul>
<li>m = 6</li>
<li>|s1| = 6</li>
<li>|s2| = 6</li>
<li>两组字符T/H和H/T要进行换位操作，因此t=2/2=1;<br>我们可以根据公式一得出Jaro得分：<script type="math/tex; mode=display">d_j = \frac{1}{3}\left(\frac{6}{|6|} + \frac{6}{|6|} + \frac{6-1}{6}\right)</script>如果使用Jaro–Winkler，并且取范围因子P=0.1,我们会得出:<br>P=0.1<br>L=3<br>$d_w = 0.944 + (3 * 0.1(1 - 0.944))=0.961$</li>
</ul>
<h3 id="python-运行"><a href="#python-运行" class="headerlink" title="python 运行"></a>python 运行</h3><ol>
<li><p>安装lib</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install jaro_winkler</span><br></pre></td></tr></table></figure>
</li>
<li><p>程序运行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">print(jaro.jaro_metric(&quot;MARTHA&quot;.decode(&quot;utf-8&quot;),&quot;MARHTA&quot;.decode(&quot;utf-8&quot;)))</span><br></pre></td></tr></table></figure>
</li>
</ol>
<h3 id="优化"><a href="#优化" class="headerlink" title="优化"></a>优化</h3><ol>
<li>多进程</li>
<li>pandas</li>
</ol>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/05/08/alias_tag/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Frone Xie">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Frone's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/05/08/alias_tag/" itemprop="url">名片别名标注</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-05-08T16:31:19+08:00">
                2017-05-08
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/IMORA/" itemprop="url" rel="index">
                    <span itemprop="name">IMORA</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2017/05/08/alias_tag/" class="leancloud_visitors" data-flag-title="名片别名标注">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="名片别名标注"><a href="#名片别名标注" class="headerlink" title="名片别名标注"></a>名片别名标注</h2><h3 id="一-业务整体流程"><a href="#一-业务整体流程" class="headerlink" title="一.业务整体流程"></a>一.业务整体流程</h3><p>为满足整体橙子语音检索时的需要，为名片现有数据自动添加标签。目前主要包括四部分：</p>
<ul>
<li>根据职位头衔为高管级姓名后添加称呼，如总、董等。</li>
<li>为公司名添加别名，如北京橙鑫数据科技有限公司的别名为橙鑫或IMORA</li>
<li>从公司名通过切词来提取中心词，为公司名增加标签</li>
<li>从公司基本信息表获取城市字段，加为标签</li>
</ul>
<p>1.<strong>数据来源：</strong><br>可能涉及到如下数据表</p>
<ul>
<li>别名信息表<br>oradt_cloud_test2.contact_card_removeword_alias</li>
<li>公司别名表<br>oradt_cloud_test2.orange_company_alias</li>
</ul>
<p>2.<strong>整体处理流程</strong><br>本系统使用到名片基本信息，需要在名片基本信息拓展系统处理之后运行，处理流程如下图：<br><img src="http://wx3.sinaimg.cn/mw690/006nSoSwly1ffe26sy9vpj30l40dc3z3.jpg" alt=""><br>图片备份位置：/home/samba/share/mengqian/handover/名片信息拓展/alias-step.png</p>
<ul>
<li>对应到代码，整体的入口为main，主要用来通过时间区间来控制需要计算的数据起始时间。并调用jobContrl中的读取数据、处理数据及序列化的方法，控制程序流程。</li>
<li>城市标签<br>由于添加城市标签功能为后续添加，没有修改整体处理流程，添加到main中，其他任务结束后，追加更新别名表中的city字段。</li>
<li>由jobContrl实现数据输入输出格式的转换,业务处理逻辑调用dataPreprocessing实现。</li>
<li>dataPreprocessing 调用各个功能模块，拼合结果数据。</li>
</ul>
<h3 id="二-功能模块说明"><a href="#二-功能模块说明" class="headerlink" title="二.功能模块说明"></a>二.功能模块说明</h3><p>主要功能模块的包结构如下图：<br><img src="http://wx1.sinaimg.cn/mw690/006nSoSwly1ffe1e2slwuj30q50c60vb.jpg" alt=""><br>图片备份位置：/home/samba/share/mengqian/handover/名片信息拓展/alias-classes.png</p>
<ul>
<li>公司名关键词提取<br>orgKeyWords</li>
<li>公司别名<br>companyAlias</li>
<li>姓氏后缀<br>respectedTitle</li>
</ul>
<h3 id="三-项目部署"><a href="#三-项目部署" class="headerlink" title="三.项目部署"></a>三.项目部署</h3><ul>
<li><p>当前每日任务部署于： 101.251.193.28:/home/mqian/orange_namecard_tagging<br>由crontab每天凌晨4点执行，本系统的需要使用到名片基础信息，需要在名片拓展系统任务完成之后运行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">####为企业打别名、人名后加称呼等打标签</span><br><span class="line">0 4 * * * /usr/local/bin/python /home/mqian/orange_namecard_tagging/main.py &gt;&gt;</span><br><span class="line">home/mqian/aliaslog.log</span><br></pre></td></tr></table></figure>
</li>
<li><p>git位置<br><a href="http://192.168.30.251:10086/git/mengqian/orange_namecard_tagging.git" target="_blank" rel="noopener">http://192.168.30.251:10086/git/mengqian/orange_namecard_tagging.git</a></p>
</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/04/28/namecard_extra/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Frone Xie">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Frone's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/04/28/namecard_extra/" itemprop="url">名片信息拓展系统</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-04-28T10:14:01+08:00">
                2017-04-28
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/IMORA/" itemprop="url" rel="index">
                    <span itemprop="name">IMORA</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2017/04/28/namecard_extra/" class="leancloud_visitors" data-flag-title="名片信息拓展系统">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="名片信息拓展系统"><a href="#名片信息拓展系统" class="headerlink" title="名片信息拓展系统"></a>名片信息拓展系统</h2><h3 id="一-业务整体流程"><a href="#一-业务整体流程" class="headerlink" title="一.业务整体流程"></a>一.业务整体流程</h3><p>名片信息拓展系统主要包括两大任务：一.从json格式的数据源提取所需要字段，入dm库供数据挖掘等使用。二.在基础信息上进行拓展，以获得更丰富的数据。</p>
<p>现用到的json字段有：姓名，手机，公司名，公司电话，职位<br>拓展字段：手机→城市，公司名→行业，公司电话→城市，职位+行业→职能</p>
<p>1.<strong>数据来源：</strong><br>可能涉及到如下数据表</p>
<ul>
<li>名片基本信息，json格式<br>oradt_cloud_test2.contact_card<br>oradt_cloud_test2.contact_card_extend</li>
<li>手机、座机区号<br>dm_test.province_city_unique_code</li>
<li>行业职能对照表<br>oradt_cloud_test2.account_basic_category</li>
</ul>
<p>2.<strong>整体处理流程</strong><br>本系统的处理流程如下图：<br><img src="http://i4.buimg.com/4851/24a68975106791ab.png" alt=""><br>图片备份位置：/home/samba/share/mengqian/handover/名片信息拓展/step.png</p>
<ul>
<li>对应到代码，整体的入口为jobsAssigner，主要用来通过命令行参数实现运行每日任务，还是只计算给定区间的数据任务，将时间区间传给makeResultTables。</li>
<li>makeResultTables则查询不同数据源，拼合计算所需的数据格式，处理完毕后再拼合入库所需的数据格式，并执行入等库操作。</li>
<li>其中makeResultTables会调用jsonPreprocess，jsonPreprocess主要任务为接受从makeResultTables所传递的时间区间，取出该区间中json数据的结果，拼合为后续信息拓展流程所需的数据格式。</li>
</ul>
<h3 id="二-功能模块说明"><a href="#二-功能模块说明" class="headerlink" title="二.功能模块说明"></a>二.功能模块说明</h3><p>主要功能模块的包结构如下图：<br><img src="http://i1.piimg.com/4851/4d54fb562381507a.jpg" alt=""><br>图片备份位置：/home/samba/share/mengqian/handover/名片信息拓展/pakages.png</p>
<p>信息拓展的各个模块，结构类似，输入数据格式为pandas.Dataframe，通过prepare()方法转换格式后，传递给transform()方法进行计算。</p>
<h3 id="三-项目部署"><a href="#三-项目部署" class="headerlink" title="三.项目部署"></a>三.项目部署</h3><ul>
<li><p>当前每日任务部署于： 101.251.193.28:/home/mqian/3366<br>由crontab每天凌晨3点执行(3388的暂时弃用)</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">#每天凌晨3点整执行，名片数据解析</span><br><span class="line">#0 3 * * *  /usr/local/bin/python /home/mqian/3388/jobsAssigner.py -d 2&gt;&gt; /home/mqian/3388/log3388</span><br><span class="line">0 3 * * *  /usr/local/bin/python /home/mqian/3366/jobsAssigner.py -d 2&gt;&gt; /home/mqian/3366/log3366</span><br></pre></td></tr></table></figure>
</li>
<li><p>git位置<br><a href="http://192.168.30.251:10086/git/mengqian/namecard_info_extra_basic.git" target="_blank" rel="noopener">http://192.168.30.251:10086/git/mengqian/namecard_info_extra_basic.git</a></p>
</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/03/02/meeting/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Frone Xie">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Frone's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/03/02/meeting/" itemprop="url">月报会议模块</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-02T14:31:19+08:00">
                2017-03-02
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/IMORA/" itemprop="url" rel="index">
                    <span itemprop="name">IMORA</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2017/03/02/meeting/" class="leancloud_visitors" data-flag-title="月报会议模块">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="会议相关月报样板"><a href="#会议相关月报样板" class="headerlink" title="会议相关月报样板"></a>会议相关月报样板</h3><p>您xx月共参加了xx ×x小时的会议，与xx个人进行过会晤，最近较为关注的公司有xx,xx,xx(公司名)<br>(数据取自日程，会晤人取日程参与人，关注公司取参与会议的人次较多的前三名公司；会议仅包括：橙子日程中从橙脉和手机日历获取的日程）</p>
<h3 id="参加会议时间"><a href="#参加会议时间" class="headerlink" title="参加会议时间"></a>参加会议时间</h3><p>oradt_cloud1520.contact_card_schedule 取会议开始结束时间；<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line">select user_id,SUM(meeting_time) as total_schedule_hour from(</span><br><span class="line">select a.id as schedule_id,a.user_id,content,title,</span><br><span class="line">FROM_UNIXTIME(start_time) as start_time,</span><br><span class="line">FROM_UNIXTIME(end_time) as end_time,</span><br><span class="line">(end_time - start_time)/(60*60*24) as day_diff,</span><br><span class="line">case</span><br><span class="line">-- 本月开始结束且一天之内结束</span><br><span class="line">when (end_time - start_time)/(60*60*24) &lt;= 1 and MONTH(FROM_UNIXTIME(start_time)) = 3 and MONTH(FROM_UNIXTIME(end_time))=3 </span><br><span class="line">then round((end_time - start_time)/(60*60)) </span><br><span class="line">-- 本月开始结束且一天之内没有结束</span><br><span class="line">when (end_time - start_time)/(60*60*24) &gt; 1 and MONTH(FROM_UNIXTIME(start_time)) = 3 and MONTH(FROM_UNIXTIME(end_time))=3 </span><br><span class="line">then round((end_time - start_time)/(60*60*24) * 8) </span><br><span class="line">-- 结束时间不是本月，则取月初第一天为结束时间</span><br><span class="line">when (end_time - start_time)/(60*60*24) &gt; 1 and MONTH(FROM_UNIXTIME(start_time)) = 3 and MONTH(FROM_UNIXTIME(end_time))!=3 </span><br><span class="line">then round((UNIX_TIMESTAMP(last_day(curdate())) - start_time)/(60*60*24) * 8) </span><br><span class="line">-- 开始时间不是本月，则取月初第一天为开始时间 </span><br><span class="line">when (end_time - start_time)/(60*60*24) &gt; 1 </span><br><span class="line">and MONTH(FROM_UNIXTIME(start_time)) != 3 and MONTH(FROM_UNIXTIME(start_time)) != 3 and MONTH(FROM_UNIXTIME(end_time))=3 </span><br><span class="line">then round((end_time - UNIX_TIMESTAMP(DATE_ADD(curdate(),interval -day(curdate())+1 day)))/(60*60*24) * 8)</span><br><span class="line">end as meeting_time</span><br><span class="line">from oradt_cloud1520.contact_card_schedule a </span><br><span class="line">right join oradt_cloud1520.contact_card_schedule_map b on a.id = b.schedule_id</span><br><span class="line">left join(</span><br><span class="line">select user_id,uuid</span><br><span class="line">    from oradt_cloud1520.contact_card</span><br><span class="line">    where self=&apos;true&apos; and status = &apos;active&apos;</span><br><span class="line">) as c on c.user_id = a.user_id and c.uuid = b.uuid </span><br><span class="line">WHERE a.start_time &gt;0 and a.end_time &gt; a.start_time </span><br><span class="line">and b.status != 0 and b.uuid != &apos;&apos; and c.uuid is null and a.status = 1</span><br><span class="line">and YEAR(FROM_UNIXTIME(start_time)) = 2017 and YEAR(FROM_UNIXTIME(end_time))=2017</span><br><span class="line">and (MONTH(FROM_UNIXTIME(start_time)) = 3 or MONTH(FROM_UNIXTIME(end_time))=3)</span><br><span class="line">order by user_id,schedule_id</span><br><span class="line">)c GROUP BY user_id;</span><br></pre></td></tr></table></figure></p>
<h3 id="名片角色总会见人数"><a href="#名片角色总会见人数" class="headerlink" title="名片角色总会见人数"></a>名片角色总会见人数</h3><p>先统计每个人参加了几个会议（会议需要去重）<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">select user_id, GROUP_CONCAT(DISTINCT(schedule_id)) as meeting_list from(</span><br><span class="line">select a.user_id, a.id as schedule_id</span><br><span class="line">from oradt_cloud1520.contact_card_schedule a</span><br><span class="line">right join oradt_cloud1520.contact_card_schedule_map b on a.id = b.schedule_id</span><br><span class="line">left join(</span><br><span class="line">select user_id,uuid</span><br><span class="line">    from oradt_cloud1520.contact_card</span><br><span class="line">    where self=&apos;true&apos; and status = &apos;active&apos;</span><br><span class="line">) as c on c.user_id = a.user_id and c.uuid = b.uuid  </span><br><span class="line">WHERE a.start_time &gt;0 and a.end_time &gt; a.start_time </span><br><span class="line">and b.status != 0 and b.uuid != &apos;&apos; and c.uuid is null and a.status = 1</span><br><span class="line">and YEAR(FROM_UNIXTIME(start_time)) = 2017 and YEAR(FROM_UNIXTIME(end_time))=2017</span><br><span class="line">and (MONTH(FROM_UNIXTIME(start_time)) = 3 or MONTH(FROM_UNIXTIME(end_time))= 3)</span><br><span class="line">order by schedule_id,user_id</span><br><span class="line">) a GROUP BY user_id;</span><br></pre></td></tr></table></figure></p>
<p>然后分别统计每个人的会议时长<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">select DISTINCT(count(uuid)) from oradt_cloud1520.contact_card_schedule_map where status != 0 and uuid != &apos;&apos; and</span><br><span class="line">schedule_id in (3260,3890,3895,3915,4249,4252,4254,4255,4280,4822);</span><br></pre></td></tr></table></figure></p>
<h3 id="关注公司"><a href="#关注公司" class="headerlink" title="关注公司"></a>关注公司</h3><p>oradt_cloud1520.contact_card_schedule_map 取uuid，即参与人；<br>与DM库中公司表关联得到参与人公司,统计公司前三位<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">select user_id, GROUP_CONCAT(companyName ORDER BY com_count desc,last_modified desc) as com_list from(</span><br><span class="line">select user_id,companyName,count(*) as com_count,max(last_modified) as last_modified from(</span><br><span class="line">select d.*,FROM_UNIXTIME(g.last_modified) as last_modified from(</span><br><span class="line">select a.user_id,b.schedule_id,b.uuid,c.companyName</span><br><span class="line">from oradt_cloud1520.contact_card_schedule a </span><br><span class="line">right join oradt_cloud1520.contact_card_schedule_map b on a.id = b.schedule_id</span><br><span class="line">left JOIN(select DISTINCT user_id,card_id,companyName from dm_test.company_info_jsonver) as c on b.uuid = c.card_id</span><br><span class="line">left join(</span><br><span class="line">select user_id,uuid</span><br><span class="line">    from oradt_cloud1520.contact_card</span><br><span class="line">    where self=&apos;true&apos; and status = &apos;active&apos;</span><br><span class="line">) as f on f.user_id = a.user_id and f.uuid = b.uuid</span><br><span class="line">WHERE a.start_time &gt; 0 and a.end_time &gt; a.start_time </span><br><span class="line">and b.status != 0 and b.uuid != &apos;&apos; and f.uuid is null and a.status = 1</span><br><span class="line">and YEAR(FROM_UNIXTIME(start_time)) = 2017 and YEAR(FROM_UNIXTIME(end_time))=2017</span><br><span class="line">and (MONTH(FROM_UNIXTIME(start_time)) = 3 or MONTH(FROM_UNIXTIME(end_time))= 3)</span><br><span class="line">and c.companyName !=&apos;&apos; and c.companyName is NOT null</span><br><span class="line">)d left join oradt_cloud1520.contact_card g on g.uuid = d.uuid) h</span><br><span class="line">GROUP BY user_id,companyName ORDER BY com_count desc,last_modified desc</span><br><span class="line">)e GROUP BY user_id;</span><br></pre></td></tr></table></figure></p>
<h3 id="相关表结构"><a href="#相关表结构" class="headerlink" title="相关表结构"></a>相关表结构</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line">CREATE TABLE `contact_card_schedule` (</span><br><span class="line">  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT &apos;主键&apos;,</span><br><span class="line">  `user_id` char(40) CHARACTER SET utf8 NOT NULL DEFAULT &apos;&apos; COMMENT &apos;创建人user_id&apos;,</span><br><span class="line">  `vcard_id` char(32) CHARACTER SET utf8 DEFAULT &apos;&apos; COMMENT &apos;日程名片id&apos;,</span><br><span class="line">  `content` text NOT NULL COMMENT &apos;日程内容&apos;,</span><br><span class="line">  `title` varchar(100) DEFAULT &apos;&apos; COMMENT &apos;日程标题&apos;,</span><br><span class="line">  `address` varchar(300) DEFAULT &apos;&apos; COMMENT &apos;地址&apos;,</span><br><span class="line">  `start_time` int(10) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;日程开始时间&apos;,</span><br><span class="line">  `end_time` int(10) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;日程结束时间&apos;,</span><br><span class="line">  `remind_time` int(10) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;提醒时间&apos;,</span><br><span class="line">  `cycle` int(10) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;提醒周期（例：15分钟为900单位为秒）&apos;,</span><br><span class="line">  `isallday` tinyint(1) NOT NULL DEFAULT &apos;2&apos; COMMENT &apos;是否全天 ：1是  2否 &apos;,</span><br><span class="line">  `flag_time` int(10) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;提醒计算字段（为时间戳）&apos;,</span><br><span class="line">  `last_modify` int(10) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;最后修改时间&apos;,</span><br><span class="line">  `create_time` int(10) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;创建时间&apos;,</span><br><span class="line">  `latitude` decimal(13,8) NOT NULL DEFAULT &apos;0.00000000&apos; COMMENT &apos;坐标&apos;,</span><br><span class="line">  `longitude` decimal(13,8) NOT NULL DEFAULT &apos;0.00000000&apos; COMMENT &apos;坐标&apos;,</span><br><span class="line">  `is_remind` tinyint(1) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;是否提醒&apos;,</span><br><span class="line">  `status` tinyint(1) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;1为添加2为删除&apos;,</span><br><span class="line">  `flight_id` int(20) DEFAULT &apos;0&apos; COMMENT &apos;行程卡id&apos;,</span><br><span class="line">  `schedule_from` tinyint(2) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;日程来源：1.为橙脉2.为手机同步3.短信同步为4.为行程卡5.为还款同步6.航旅卡&apos;,</span><br><span class="line">  `schedule_info` text CHARACTER SET utf8 COMMENT &apos;来源模块信息&apos;,</span><br><span class="line">  `orange_remind` int(10) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;橙子专用提醒时间&apos;,</span><br><span class="line">  PRIMARY KEY (`id`),</span><br><span class="line">  KEY `user_id` (`user_id`),</span><br><span class="line">  KEY `v_cardid_idx` (`vcard_id`) USING BTREE</span><br><span class="line">) ENGINE=InnoDB AUTO_INCREMENT=4771 DEFAULT CHARSET=utf8mb4</span><br><span class="line"></span><br><span class="line">CREATE TABLE `contact_card_schedule_map` (</span><br><span class="line">  `id` int(20) unsigned NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `uuid` char(32) NOT NULL DEFAULT &apos;&apos; COMMENT &apos;邀请人cardid&apos;,</span><br><span class="line">  `schedule_id` bigint(20) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;日程id&apos;,</span><br><span class="line">  `last_modify` int(10) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;最后更新时间&apos;,</span><br><span class="line">  `operation` enum(&apos;delete&apos;,&apos;modify&apos;,&apos;add&apos;) NOT NULL COMMENT &apos;参与人状态&apos;,</span><br><span class="line">  `status` tinyint(1) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;0 不参与 1 未接受 2 已接受 3 完成&apos;,</span><br><span class="line">  PRIMARY KEY (`id`),</span><br><span class="line">  KEY `sch_id` (`schedule_id`) USING BTREE,</span><br><span class="line">  KEY `v_uuid_index` (`uuid`) USING BTREE</span><br><span class="line">) ENGINE=InnoDB AUTO_INCREMENT=7093 DEFAULT CHARSET=utf8mb4</span><br><span class="line"></span><br><span class="line">CREATE TABLE `orange_meeting_follow` (</span><br><span class="line">  `id` int(10) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `user_id` varchar(42) NOT NULL COMMENT &apos;用户id&apos;,</span><br><span class="line">  `meeting_hour` int(2) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;会议小时数&apos;,</span><br><span class="line">  `meeting_people` int(2) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;面谈人数&apos;,</span><br><span class="line">  `follow_comp` text COMMENT &apos;关注公司列表&apos;,</span><br><span class="line">  `report_month` int(6) NOT NULL COMMENT &apos;月报生成年月,存储格式例：201702&apos;,</span><br><span class="line">  PRIMARY KEY (`id`)</span><br><span class="line">) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COMMENT=&apos;用户会议相关及关注公司统计表&apos;</span><br></pre></td></tr></table></figure>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/02/15/monthlyReport/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Frone Xie">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Frone's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/02/15/monthlyReport/" itemprop="url">月报各统计指标计算方法</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-02-15T10:14:01+08:00">
                2017-02-15
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/IMORA/" itemprop="url" rel="index">
                    <span itemprop="name">IMORA</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2017/02/15/monthlyReport/" class="leancloud_visitors" data-flag-title="月报各统计指标计算方法">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="月报各项目计算（初版）"><a href="#月报各项目计算（初版）" class="headerlink" title="月报各项目计算（初版）"></a>月报各项目计算（初版）</h2><h3 id="一-消费记录"><a href="#一-消费记录" class="headerlink" title="一.消费记录"></a>一.消费记录</h3><p>1.<strong>数据来源：月报表</strong></p>
<pre><font size="2">CREATE TABLE `orange_monthly_report` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `user_id` varchar(42) NOT NULL COMMENT '用户ID',
  `content` text NOT NULL COMMENT '月报内容',
  `created_time` int(10) NOT NULL COMMENT '月报创建时间',
  `modify_time` int(10) NOT NULL COMMENT '处理时间',
  `report_month` varchar(6) NOT NULL COMMENT '月报生成年月',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='月报数据表';


CREATE TABLE `orange_consume_detail` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `user_id` char(42) NOT NULL COMMENT '用户id',
  `card_id` char(32) NOT NULL COMMENT '卡片id',
  `bankcard_id` char(32) NOT NULL COMMENT '银行卡号',
  `bank_name` varchar(90) NOT NULL COMMENT '银行名',
  `bill_type` tinyint(1) NOT NULL COMMENT '消费类型：1、手机银行支付，2、支取，3、转账等',
  `bill` float(10,2) NOT NULL COMMENT '消费金额',
  `balance` float(10,2) NOT NULL COMMENT '余额',
  `created_time` int(10) NOT NULL COMMENT '创建时间',
  `modify_time` int(10) NOT NULL COMMENT '修改时间',
  `report_month` varchar(6) NOT NULL COMMENT '月报生成年月',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COMMENT='消费详情表';
</font></pre>


<p>2.<strong>消费记录详情SQL</strong></p>
<p>得到指定月份的用户消费详情<br>提供各卡片当月消费金额</p>
<pre><font size="2">SELECT user_id, bankcard_id,bill_time,cons_type,bill FROM consume_details
WHERE  MONTH(bill_time) == "%s" AND user_id = "%s"</font></pre>

<font color="red" size="2">待定：短信去重</font>


<h3 id="二-我在旅途"><a href="#二-我在旅途" class="headerlink" title="二.我在旅途"></a>二.我在旅途</h3><p>1.<strong>数据来源：里程卡，酒店卡</strong></p>
<font color="red" size="2">待定：</font>

<pre><code>2.里程卡中可能无法得到飞行次数数据。
3.里程数可能无法涵盖所有公司。
4.酒店卡数据来源？？
</code></pre><p>5.抵达城市算法，只用手机GPS位置   </p>
<h3 id="三-人脉动态"><a href="#三-人脉动态" class="headerlink" title="三.人脉动态"></a>三.人脉动态</h3><p>1.新增名片数，新增好友数<br>从数据库中获取新增名片数，新增好友数</p>
<p>新增好友数计算：contact_card(is_friend,from_uid,created_time)。从该表中按创建时间分组后取好友uid最早的记录，看是否落入统计区间。</p>
<p>2.被关注人数<br>来自谁看过我的消费结果<br>contact_card_see_me_source(未去重）<br>统计自然月的关注过用户的人数</p>
<p>3.参加会议时间 </p>
<p><a href="http://192.168.30.191/example/orange_schedule.txt" target="_blank" rel="noopener">http://192.168.30.191/example/orange_schedule.txt</a><br>日程相关说明</p>
<pre><code>oradt_cloud1520.contact_card_schedule 取会议开始结束时间；
</code></pre><p>4.关注公司</p>
<pre><code>oradt_cloud1520.contact_card_schedule_map 取uuid，即参与人；    
与DM库中公司表关联得到参与人公司,统计公司前三位。如有参与人公司排名相同的情况，取名片更新时间最新的公司。
</code></pre><h3 id="四-卡片统计"><a href="#四-卡片统计" class="headerlink" title="四.卡片统计"></a>四.卡片统计</h3><p>日志中获取卡片展示超过5秒的所有卡片，每找到一对展示开始时间超过5秒的记录，认为是一次使用，记入DM库</p>
<pre><font size="2">CREATE TABLE `card_used_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `user_id` char(40) DEFAULT '' COMMENT '用户id',
  `card_id` char(32) DEFAULT '' COMMENT '卡片id',
  `daily_used_count` int(10) DEFAULT '' COMMENT '卡片当日使用次数',
  `card_type` char(32) DEFAULT '' COMMENT '卡片类型',
  `used_time` datetime COMMENT '卡片使用时间',
  `batch_time` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='卡片使用次数表'</font></pre>

<p>展示结果为按日别、卡别、用户统计使用次数<br>各类卡使用占比则先分组<br>常用卡列表来自于hive</p>
<h3 id="附录"><a href="#附录" class="headerlink" title="附录"></a>附录</h3><p>月报json存储格式</p>
<pre><font size="2">{
    "consume": {
        "totle": 58097.86,
        "bank": [
            {
                "bank_name": "招商银行",
                "card_num": 1234567898765,
                "amount": 300.23
            },
            {
                "bank_name": "招商银行",
                "card_num": 9876543212345,
                "amount": 451.8
            },
            {
                "bank_name": "工商银行",
                "card_num": 66436743634424,
                "amount": 670.83
            },
            {
                "bank_name": "建设银行",
                "card_num": 63762343254654,
                "amount": 1270.31
            }
        ]
    },
    "travel": {
        "flight": 28,
        "mileage": 10867,
        "stay": 15,
        "city": "北京、东京、纽约、斯德哥尔摩"
    },
    "connection": {
        "meeting_hour": 28,
        "meeting_people": 15,
        "new_friend": 98,
        "new_card": 887,
        "followed": 185,
        "follow_comp": "苹果、google、三星"
    },
    "card": {
        "category": [
            {
                "type": "行程卡",
                "freq": 90
            },
            {
                "type": "名片",
                "freq": 50
            },
            {
                "type": "酒店卡",
                "freq": 50
            },
            {
                "type": "系统卡",
                "freq": 10
            },
            {
                "type": "other",
                "freq": 100
            }
        ],
        "recent_use": "33829923329,53829923329,9829923380"
    }
}

** 此处的 other是取使用在4次以上，并不在前4位的卡片，非卡片类型的其它卡片
</font></pre> 


          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/02/14/message_pushing/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Frone Xie">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Frone's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/02/14/message_pushing/" itemprop="url">资讯推送|用户推广|活动管理</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-02-14T02:14:14+08:00">
                2017-02-14
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/IMORA/" itemprop="url" rel="index">
                    <span itemprop="name">IMORA</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2017/02/14/message_pushing/" class="leancloud_visitors" data-flag-title="资讯推送|用户推广|活动管理">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="整体启动"><a href="#整体启动" class="headerlink" title="整体启动"></a>整体启动</h3><p>main.py</p>
<p>通过多线程同时进行三个任务 (确保每个环境只有一个进程在运行)<br>nohup python main.py&amp;</p>
<h4 id="相关配置"><a href="#相关配置" class="headerlink" title="相关配置"></a>相关配置</h4><p>配置写在文件 db.conf中<br>只需要根据运行环境更改数据库的配置名称即可，如：<br>oa = operationActivity.OperationActivity(“database_dev”) // 192<br>oa = operationActivity.OperationActivity(“database_prd”) // 125</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br></pre></td><td class="code"><pre><span class="line"># !/Users/xieqj/py_env/venv python</span><br><span class="line"># -*- coding: utf-8 -*-</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">import threading</span><br><span class="line">from mg_handling import msgPushing, userPromotion, operationActivity</span><br><span class="line">import util.comm as cm</span><br><span class="line">import time</span><br><span class="line"></span><br><span class="line"># 资讯推送</span><br><span class="line">def msg_pushing():</span><br><span class="line">    while (True):</span><br><span class="line">        mp = msgPushing.MsgPushing()</span><br><span class="line">        msg_contents = mp.scanDBForSending()</span><br><span class="line">        mp.insert_msg2mq(msg_contents)</span><br><span class="line">        mp.mark_msg_as_sent(msg_contents)</span><br><span class="line">        mp.close_database()</span><br><span class="line">        time.sleep(8)</span><br><span class="line"></span><br><span class="line"># 用户推广</span><br><span class="line">def user_promotion():</span><br><span class="line">    while (True):</span><br><span class="line">        mp = userPromotion.UserPromotion()</span><br><span class="line">        msg_contents = mp.scanDBForSending()</span><br><span class="line">        mp.insert_msg2mq(msg_contents)</span><br><span class="line">        mp.mark_msg_as_sent(msg_contents)</span><br><span class="line">        mp.close_database()</span><br><span class="line">        time.sleep(8)</span><br><span class="line"></span><br><span class="line"># 活动管理</span><br><span class="line">def operation_activity():</span><br><span class="line">    while (True):</span><br><span class="line">        oa = operationActivity.OperationActivity()</span><br><span class="line">        msg_contents = oa.scanDBForSending()</span><br><span class="line">        oa.insert_msg2mq(msg_contents)</span><br><span class="line">        oa.mark_msg_as_sent(msg_contents)</span><br><span class="line">        oa.close_database()</span><br><span class="line">        time.sleep(8)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"># 通过多线程同时启动两个步骤</span><br><span class="line">if __name__ == &quot;__main__&quot;:</span><br><span class="line">    cm.initLog(&quot;pushing.log&quot;, &quot;INFO&quot;)</span><br><span class="line">    threads = []</span><br><span class="line">    t1 = threading.Thread(target=msg_pushing)</span><br><span class="line">    threads.append(t1)</span><br><span class="line">    t2 = threading.Thread(target=user_promotion)</span><br><span class="line">    threads.append(t2)</span><br><span class="line">    t3 = threading.Thread(target=operation_activity)</span><br><span class="line">    threads.append(t3)</span><br><span class="line">    for t in threads:</span><br><span class="line">        t.setDaemon(True)</span><br><span class="line">        t.start()</span><br><span class="line">    t.join()</span><br></pre></td></tr></table></figure>
<h3 id="资讯推送"><a href="#资讯推送" class="headerlink" title="资讯推送"></a>资讯推送</h3><p>读取表 sns_qa_push_setting 中的资讯，将其按照region，industry，func（职能）推送给对应群组的用户。<br>具体方法就是将表 sns_qa_push_setting 中的 content 1对1的推送给表 account_basic 中对应群组的用户，即插入 message_queue 表。</p>
<p>需要注意控制推送时间，和在推送后 update 表 sns_qa_push_setting 中 status 字段</p>
<h4 id="仓库位置"><a href="#仓库位置" class="headerlink" title="仓库位置"></a>仓库位置</h4><p>git@192.168.30.251:message_handling.git</p>
<p>{“messagetype”: 230,”params”: { “data”: [{“newsid”: “ EwtNMSASOSvxjerhni98uQyEXnDIp9fS”,”title”: “发布到审核”,”url”: “资讯  URL”, “coverurl”: “https: //oradtdev.s3.cn-north-  1.amazonaws.com.cn/ukIv0BqxtnjRgjuhJcGKO6jze1liPmZE/gm9YtnBtvQ20160921132139.jpg”,”createdtime”: “1474435299” } ]}}</p>
<h4 id="数据表"><a href="#数据表" class="headerlink" title="数据表"></a>数据表</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br></pre></td><td class="code"><pre><span class="line">CREATE TABLE `industry_category` (</span><br><span class="line">  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `category_id` char(8) NOT NULL,</span><br><span class="line">  `parent_id` char(8) NOT NULL,</span><br><span class="line">  `name` varchar(128) NOT NULL COMMENT &apos;行业名称&apos;,</span><br><span class="line">  PRIMARY KEY (`id`)</span><br><span class="line">) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=&apos;国家统计局的两级行业分类标准&apos;</span><br><span class="line"></span><br><span class="line"># 保存从名片的json数据解析出来的数据 name * region</span><br><span class="line">CREATE TABLE `card_info_jsonver` (</span><br><span class="line">  `id` bigint(20) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `card_id` char(32) DEFAULT &apos;&apos; COMMENT &apos;名片id&apos;,</span><br><span class="line">  `user_id` char(40) DEFAULT &apos;&apos; COMMENT &apos;用户id&apos;,</span><br><span class="line">  `side` tinyint(4) DEFAULT &apos;0&apos; COMMENT &apos;名片的正反面，0：正面，1：反面&apos;,</span><br><span class="line">  `name` varchar(128) DEFAULT &apos;&apos; COMMENT &apos;名片上的名字&apos;,</span><br><span class="line">  `mobile` varchar(20) DEFAULT &apos;&apos; COMMENT &apos;手机号&apos;,</span><br><span class="line">  `provinceM` varchar(64) DEFAULT &apos;&apos; COMMENT &apos;手机号解出来的省份&apos;,</span><br><span class="line">  `provinceM_code` varchar(16) DEFAULT &apos;&apos; COMMENT &apos;省份编码&apos;,</span><br><span class="line">  `cityM` varchar(64) DEFAULT &apos;&apos; COMMENT &apos;城市&apos;,</span><br><span class="line">  `cityM_code` varchar(16) DEFAULT &apos;&apos; COMMENT &apos;城市编码&apos;,</span><br><span class="line">  `created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT &apos;名片创建时间&apos;,</span><br><span class="line">  `updated_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT &apos;名片更新时间&apos;,</span><br><span class="line">  `handle_state` varchar(16) DEFAULT &apos;&apos; COMMENT &apos;处理状态&apos;,</span><br><span class="line">  PRIMARY KEY (`id`)</span><br><span class="line">) ENGINE=InnoDB AUTO_INCREMENT=42333 DEFAULT CHARSET=utf8 COMMENT=&apos;保存从名片的json数据解析出来的数据&apos;</span><br><span class="line"></span><br><span class="line"># 从名片json数据解析出来的公司信息 companyName * func</span><br><span class="line">CREATE TABLE `company_info_jsonVer` (</span><br><span class="line">  `id` bigint(20) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `card_id` char(32) DEFAULT NULL COMMENT &apos;名片id&apos;,</span><br><span class="line">  `user_id` char(40) DEFAULT NULL COMMENT &apos;用户id&apos;,</span><br><span class="line">  `companyName` varchar(128) DEFAULT NULL COMMENT &apos;公司名称&apos;,</span><br><span class="line">  `industry` varchar(128) DEFAULT NULL COMMENT &apos;二级行业&apos;,</span><br><span class="line">  `ind_code` char(8) DEFAULT NULL COMMENT &apos;二级行业编码&apos;,</span><br><span class="line">  `title` char(64) DEFAULT NULL COMMENT &apos;职位&apos;,</span><br><span class="line">  `func_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT &apos;职能名称&apos;,</span><br><span class="line">  `func_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT &apos;职能编号&apos;,</span><br><span class="line">  PRIMARY KEY (`id`)</span><br><span class="line">) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=&apos;从名片json数据解析出来的公司信息&apos;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">消息类型</span><br><span class="line"> </span><br><span class="line">&#123;</span><br><span class="line">    &quot;messagetype&quot;: 230,</span><br><span class="line">    &quot;params&quot;: &#123;</span><br><span class="line">        &quot;data&quot;: [</span><br><span class="line">            &#123;</span><br><span class="line">                &quot;newsid&quot;: 资讯id,   </span><br><span class="line">                &quot;title&quot;: &quot;资讯标题&quot;,</span><br><span class="line">               &quot;url&quot;: &quot;资讯URL&quot;,</span><br><span class="line">                &quot;coverurl&quot;: &quot;封面URL&quot;,</span><br><span class="line">            &#125;,</span><br><span class="line">            ....</span><br><span class="line">        ]</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">注：排序 按照data中数组的顺序</span><br></pre></td></tr></table></figure>
<hr>
<h3 id="用户推广"><a href="#用户推广" class="headerlink" title="用户推广"></a>用户推广</h3><p>基本流程与咨询推送相同</p>
<h4 id="仓库位置-1"><a href="#仓库位置-1" class="headerlink" title="仓库位置"></a>仓库位置</h4><p>git@192.168.30.251:message_handling.git</p>
<p>git@192.168.30.251:effective.git</p>
<p>userPromotion.py</p>
<h4 id="推广表"><a href="#推广表" class="headerlink" title="推广表"></a>推广表</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line">CREATE TABLE `sys_user_promotion` (</span><br><span class="line">  `id` int(11) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `pro_id` char(32) NOT NULL COMMENT &apos;推广ID&apos;,</span><br><span class="line">  `type` tinyint(2) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;推送方式：1：内部 2：邮件 3：短信&apos;,</span><br><span class="line">  `isalluser` tinyint(2) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;1发送注册用户2发送全部用户&apos;,</span><br><span class="line">  `push_time` int(10) NOT NULL COMMENT &apos;设置的推送时间&apos;,</span><br><span class="line">  `region` varchar(2000) NOT NULL DEFAULT &apos;&apos; COMMENT &apos;地区（多个,号隔开）&apos;,</span><br><span class="line">  `industry` varchar(2000) NOT NULL DEFAULT &apos;&apos; COMMENT &apos;行业（多个,号隔开）&apos;,</span><br><span class="line">  `func` varchar(2000) NOT NULL DEFAULT &apos;&apos; COMMENT &apos;职能（多个,号隔开）&apos;,</span><br><span class="line">  `title` varchar(50) CHARACTER SET utf8mb4 DEFAULT &apos;&apos; COMMENT &apos;标题&apos;,</span><br><span class="line">  `content` text NOT NULL COMMENT &apos;推送的内容&apos;,</span><br><span class="line">  `created_time` int(10) NOT NULL COMMENT &apos;添加时间&apos;,</span><br><span class="line">  `admin_id` char(40) NOT NULL DEFAULT &apos;&apos; COMMENT &apos;设置人&apos;,</span><br><span class="line">  `status` tinyint(2) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;状态 1：未发 2：已发&apos;,</span><br><span class="line">  `isntice` tinyint(2) DEFAULT &apos;0&apos; COMMENT &apos;是否通知&apos;,</span><br><span class="line">  `url` varchar(256) NOT NULL COMMENT &apos;url地址&apos;,</span><br><span class="line">  `json_data` text NOT NULL COMMENT &apos;推送json格式&apos;,</span><br><span class="line">  PRIMARY KEY (`id`)</span><br><span class="line">) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=utf8 COMMENT=&apos;运营后台-用户推广表&apos;</span><br><span class="line"></span><br><span class="line">-- 存储type为2，3的用户推广</span><br><span class="line">CREATE TABLE `message_promotion` (</span><br><span class="line">  `id` bigint(20) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `type` tinyint(4) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;类型：1-内部，2-邮件，3-短信&apos;,</span><br><span class="line">  `mobile` varchar(18) DEFAULT &apos;&apos; COMMENT &apos;手机号&apos;,</span><br><span class="line">  `email` varchar(256) DEFAULT &apos;&apos; COMMENT &apos;邮箱&apos;,</span><br><span class="line">  `title` varchar(100) NOT NULL DEFAULT &apos;&apos; COMMENT &apos;标题&apos;,</span><br><span class="line">  `content` text NOT NULL COMMENT &apos;消息内容&apos;,</span><br><span class="line">  `created_time` int(11) DEFAULT NULL COMMENT &apos;创建时间&apos;,</span><br><span class="line">  `modified_time` int(11) DEFAULT NULL COMMENT &apos;修改时间&apos;,</span><br><span class="line">  `status` tinyint(4) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;状态：0-未发送，1-已发送，2-发送失败&apos;,</span><br><span class="line">  PRIMARY KEY (`id`)</span><br><span class="line">) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT=&apos;推广消息表&apos;</span><br><span class="line"> </span><br><span class="line">推广消息类型</span><br><span class="line"> </span><br><span class="line">&#123;</span><br><span class="line">  &quot;messagetype&quot;:231,</span><br><span class="line">  &quot;params&quot;:&#123;</span><br><span class="line">     &quot;id&quot;:&quot;文章id&quot;，</span><br><span class="line">      &quot;title&quot;: &quot;资讯标题&quot;,</span><br><span class="line">      &quot;content&quot;:&quot;内容&quot;，</span><br><span class="line">      &quot;createdtime&quot;: &quot;1345764830&quot;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br><span class="line">&#123;</span><br><span class="line">  &quot;messagetype&quot;: 231,</span><br><span class="line">  &quot;params&quot;: &#123;</span><br><span class="line">    &quot;content&quot;: &quot;hello world！&lt;br/&gt;&quot;,</span><br><span class="line">    &quot;createdtime&quot;: 1483620281,</span><br><span class="line">    &quot;id&quot;: &quot;zlJjJD6gDvjCdoMcibqCWOGrMo7vbB0b&quot;,</span><br><span class="line">    &quot;image&quot;: &quot;&quot;,</span><br><span class="line">    &quot;title&quot;: &quot;推送测试&quot;,</span><br><span class="line">    &quot;type&quot;: &quot;user&quot;,</span><br><span class="line">    &quot;url&quot;: &quot;h5/News/secretary?type=promotion&amp;id=zlJjJD6gDvjCdoMcibqCWOGrMo7vbB0b&quot;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<hr>
<h3 id="活动管理"><a href="#活动管理" class="headerlink" title="活动管理"></a>活动管理</h3><h4 id="背景说明"><a href="#背景说明" class="headerlink" title="背景说明"></a>背景说明</h4><p>系统中，内容管理-推送、运营管理-新增推广、运营管理-新增活动页面中，地区、行业、职能选择时，弹窗样式与“内容管理-推送”样式相同，具体请参见原型</p>
<p>进行推送时，匹配规则如下：<br>a)  行业：第一次使用APP时所选行业+当前默认身份的并集。采用1级行业-2级行业模式划分<br>b)  地区：第一次使用APP时所选手机号+当前默认身份的并集。采用1级地区-2级地区模式划分<br>c)  职能：当前默认身份。采用1级行业-职能（只有1级）模式划分</p>
<p>当前默认身份cardid需要通过表 account_basic_detail 的 card_id 字段得到</p>
<h4 id="业务流程"><a href="#业务流程" class="headerlink" title="业务流程"></a>业务流程</h4><h4 id="仓库位置-2"><a href="#仓库位置-2" class="headerlink" title="仓库位置"></a>仓库位置</h4><p>git@192.168.30.251:message_handling.git</p>
<p>OperationActivity</p>
<h4 id="活动表结构"><a href="#活动表结构" class="headerlink" title="活动表结构"></a>活动表结构</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">CREATE TABLE `operation_activity` (</span><br><span class="line">  `id` int(11) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `activity_id` char(32) CHARACTER SET utf8 NOT NULL COMMENT &apos;活动id&apos;,</span><br><span class="line">  `type` tinyint(4) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;类型 1:活动 2:资讯&apos;,</span><br><span class="line">  `isnotify` tinyint(4) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;1:不通知 2:通知&apos;,</span><br><span class="line">  `push_state` tinyint(4) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;isnotify为2时有效，1:未推送，2:已推送&apos;,</span><br><span class="line">  `region` varchar(256) CHARACTER SET utf8 NOT NULL COMMENT &apos;地区（多个,号隔开）&apos;,</span><br><span class="line">  `industry` varchar(256) CHARACTER SET utf8 NOT NULL COMMENT &apos;行业（多个,号隔开）&apos;,</span><br><span class="line">  `func` varchar(256) CHARACTER SET utf8 NOT NULL COMMENT &apos;职能（多个,号隔开）&apos;,</span><br><span class="line">  `show_id` varchar(400) CHARACTER SET utf8 DEFAULT NULL COMMENT &apos;资讯shwo_id（多个,号隔开）type为2时有效&apos;,</span><br><span class="line">  `image` varchar(256) CHARACTER SET utf8 DEFAULT NULL COMMENT &apos;标题图片&apos;,</span><br><span class="line">  `title` varchar(100) CHARACTER SET utf8 DEFAULT NULL COMMENT &apos;活动标题 type为1时使用&apos;,</span><br><span class="line">  `content` text CHARACTER SET utf8 COMMENT &apos;活动标题 type为1时使用&apos;,</span><br><span class="line">  `onlinetime` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;上线时间&apos;,</span><br><span class="line">  `offlinetime` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;下线时间&apos;,</span><br><span class="line">  `user_id` char(40) CHARACTER SET utf8 NOT NULL COMMENT &apos;发布人用户id&apos;,</span><br><span class="line">  `created_time` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;创建时间&apos;,</span><br><span class="line">  `modify_time` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;修改时间&apos;,</span><br><span class="line">  `state` tinyint(4) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;状态 1:未发布 2:已发布 3:已下线 4:已删除&apos;,</span><br><span class="line">  `click_count` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;点击量&apos;,</span><br><span class="line">  `share_count` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;分享量&apos;,</span><br><span class="line">  `share_user_count` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;分享用户量&apos;,</span><br><span class="line">  `push_count` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;推送用户量&apos;,</span><br><span class="line">  `url` varchar(256) NOT NULL COMMENT &apos;URL地址&apos;,</span><br><span class="line">  `json_data` text NOT NULL,</span><br><span class="line">  PRIMARY KEY (`id`),</span><br><span class="line">  UNIQUE KEY `activity_id` (`activity_id`)</span><br><span class="line">) ENGINE=InnoDB AUTO_INCREMENT=94 DEFAULT CHARSET=utf8mb4 COMMENT=&apos;运营活动表&apos;</span><br><span class="line"></span><br><span class="line">推送类型</span><br><span class="line">&#123;</span><br><span class="line">  &quot;messagetype&quot;:231,</span><br><span class="line">  &quot;params&quot;:&#123;</span><br><span class="line">      &quot;id&quot;:&quot;文章id&quot;，</span><br><span class="line">      &quot;title&quot;: &quot;标题&quot;,</span><br><span class="line">      &quot;content&quot;:&quot;内容&quot;，</span><br><span class="line">      &quot;createdtime&quot;: &quot;1345764830&quot;,</span><br><span class="line">      &quot;image&quot;:&quot;图片URL&quot;，</span><br><span class="line">      &quot;type&quot;:&quot;活动（activity）或者用户推广（user）&quot;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<hr>
<h3 id="带推送消息查询语句"><a href="#带推送消息查询语句" class="headerlink" title="带推送消息查询语句"></a>带推送消息查询语句</h3><h4 id="资讯推送-1"><a href="#资讯推送-1" class="headerlink" title="资讯推送"></a>资讯推送</h4><p>select id,FROM_UNIXTIME(push_time) as push_time,status,region,industry,func,admin_id,content from oradt_cloud_test2.sns_qa_push_setting<br>where <code>status</code> &lt;&gt; 2 and industry != ‘’ and func != ‘’ and region != ‘’<br>and ROUND((UNIX_TIMESTAMP(SYSDATE()) - push_time)/60) &gt;= -2;</p>
<h4 id="用户推广-1"><a href="#用户推广-1" class="headerlink" title="用户推广"></a>用户推广</h4><p>select id,FROM_UNIXTIME(push_time) as push_time,status,region,industry,func,admin_id,title,json_data from oradt_cloud_test2.sys_user_promotion<br>where <code>status</code> &lt;&gt; 2 and industry != ‘’ and func != ‘’ and region != ‘’<br>and ROUND((UNIX_TIMESTAMP(SYSDATE()) - push_time)/60) &gt;= -2;</p>
<h4 id="活动推广"><a href="#活动推广" class="headerlink" title="活动推广"></a>活动推广</h4><p>select id,push_state, region, industry, func, title, json_data, user_id from oradt_cloud_test2.operation_activity<br>where push_state &lt;&gt; 2 and industry != ‘’ and func != ‘’ and region != ‘’ and ROUND((UNIX_TIMESTAMP(SYSDATE()) - push_time)/60) &gt;= -2;</p>
<hr>
<h3 id="部署情况"><a href="#部署情况" class="headerlink" title="部署情况"></a>部署情况</h3><h4 id="125仿真环境"><a href="#125仿真环境" class="headerlink" title="125仿真环境"></a>125仿真环境</h4><p>部署在IDC 云主机 /home/xieqj/python2.7_scenario/fangzhen</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">0 */1 * * * python2.7 /home/xieqj/python2.7_scenario/fangzhen/CardDeduplication/CardDeduplication3366.py</span><br></pre></td></tr></table></figure>
<p>名片去重 60分钟运行一次<br>名片异常 5分钟运行一次<br>人脉更新 60分钟运行一次<br>消息推送 main.py 60分钟一次</p>
<p>python2.7 运行的是125 3366端口<br>python2.7 message_handling/main.py (消息推送)<br>python2.7 CardDeduplication/CardDeduplication.py<br>python2.7 CardExceptionHandling/CardException.py<br>python2.7 cardUpdateNotification/CardUpdateNote.py</p>
<p>python 运行的是3388端口<br>python CardDeduplication.py<br>python CardException.py</p>
<h4 id="AWS"><a href="#AWS" class="headerlink" title="AWS"></a>AWS</h4><p>部署在ec2 54.223.28.119<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">0 0 */1 * * python2.7 /home/ec2-user/namecard/CardDeduplication/CardDeduplication_aws.py</span><br></pre></td></tr></table></figure></p>
<p>名片异常 每5分钟运行一次<br>名片去重 每24小时运行一次<br>用户推广 每1分钟运行一次<br>消息推送 每1分钟运行一次</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/02/10/Hdfs1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Frone Xie">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Frone's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/02/10/Hdfs1/" itemprop="url">Hdfs的block块</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-02-10T18:00:00+08:00">
                2017-02-10
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/spark/" itemprop="url" rel="index">
                    <span itemprop="name">spark</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2017/02/10/Hdfs1/" class="leancloud_visitors" data-flag-title="Hdfs的block块">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="Hdfs的block块"><a href="#Hdfs的block块" class="headerlink" title="Hdfs的block块"></a>Hdfs的block块</h1><p><img src="http://img.blog.csdn.net/20160415202744965" alt="image"></p>
<h1 id="MapReduce-shuffle过程"><a href="#MapReduce-shuffle过程" class="headerlink" title="MapReduce shuffle过程"></a>MapReduce shuffle过程</h1><p><img src="https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&amp;quality=100&amp;size=b4000_4000&amp;sec=1486668014&amp;di=b8a686254db1eaf60531d9d61398ce79&amp;src=http://img2.ph.126.net/ePqGrUilx_R_3YRiPsdzdw==/3130564691076091433.png" alt="image"></p>
<h1 id="Spark-RDD-shuffle过程"><a href="#Spark-RDD-shuffle过程" class="headerlink" title="Spark RDD shuffle过程"></a>Spark RDD shuffle过程</h1><p><img src="http://jerryshao.me/img/2014-01-04-spark-shuffle/mapreduce-process.jpg" alt="image"></p>
<h1 id="Spark-RDD"><a href="#Spark-RDD" class="headerlink" title="Spark RDD"></a>Spark RDD</h1><p><img src="http://img.blog.csdn.net/20151208164857435" alt="image"></p>
<h1 id="Spark-窄依赖-宽依赖"><a href="#Spark-窄依赖-宽依赖" class="headerlink" title="Spark 窄依赖 宽依赖"></a>Spark 窄依赖 宽依赖</h1><p><img src="http://img.blog.csdn.net/20151208163736558" alt="image"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/02/10/Hive3/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Frone Xie">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Frone's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/02/10/Hive3/" itemprop="url">Hive优化以及数据倾斜问题</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-02-10T18:00:00+08:00">
                2017-02-10
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Hive/" itemprop="url" rel="index">
                    <span itemprop="name">Hive</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2017/02/10/Hive3/" class="leancloud_visitors" data-flag-title="Hive优化以及数据倾斜问题">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="Hive优化以及数据倾斜问题"><a href="#Hive优化以及数据倾斜问题" class="headerlink" title="Hive优化以及数据倾斜问题"></a>Hive优化以及数据倾斜问题</h1><h2 id="HQL优化"><a href="#HQL优化" class="headerlink" title="HQL优化"></a>HQL优化</h2><p>1.调整Join顺序，确保以大表作为驱动表,即大表放在后面</p>
<p>2.去除查询中不需要的column</p>
<p>3.Where条件判断等在TableScan阶段就进行过滤</p>
<p>4.利用Partition信息，只读取符合条件的Partition</p>
<p>5.Map端join，以大表作驱动，小表载入所有mapper内存中</p>
<p>6.对于数据分布不均衡的表Group by时，为避免数据集中到少数的reducer上，分成两个map-reduce阶段。第一个阶段先用Distinct列进行shuffle，然后在reduce端部分聚合，减小数据规模，第二个map-reduce阶段再按group-by列聚合。</p>
<p>7.在map端用hash进行部分聚合，减小reduce端数据处理规模。</p>
<h2 id="数据倾斜问题"><a href="#数据倾斜问题" class="headerlink" title="数据倾斜问题"></a>数据倾斜问题</h2><p>数据倾斜<br>概念：数据倾斜是指，map /reduce程序执行时，reduce节点大部分执行完毕，但是</p>
<p>有一个或者几个reduce节点运行很慢，导致整个程序的处理时间很长，这是因为某一</p>
<p>个key的条数比其他key多很多（有时是百倍或者千倍之多），这条key所在的reduce</p>
<p>节点所处理的数据量比其他节点就大很多，从而导致某几个节点迟迟运行不完。</p>
<p>执行操作：</p>
<p>  1.其中一个表较小，但是key集中，可能会导致分发到一个或几个Reduce上的数据远高于平均值<br>  2.大表与大表关联，但是空值或者0比较多，这些控制都由一个reduce处理，非常慢。<br>  3.group by维度过小，某值的数量过多。处理某值的Reduce非常耗时。<br>  4.count distinct 某特殊值过多，处理此特殊值的Reduce耗时。</p>
<p>原因：</p>
<pre><code>1.key分布不均
2.业务数据本身的特性
3.建表时考虑不周
4.某些语句本身就有数据倾斜
</code></pre><p>解决方案：</p>
<p>  1.参数调节<br>    hive.map.aggr=true<br>    Map端部分聚合，相当于Combiner(合并器)。<br>    hive.groupby.skewindata=true<br>    有数据倾斜的时候进行负载均衡，当选项设定为 true，生成的查询计划会有两个 MR Job。</p>
<pre><code>第一个 MR Job 中，Map 的输出结果集合会随机分布到 Reduce 中，每个 Reduce 做部分

聚合操作，并输出结果，这样处理的结果是相同的 Group By Key 有可能被分发到不同的 

Reduce 中，从而达到负载均衡的目的；第二个 MR Job 再根据预处理的数据结果按照 Group By Key 

分布到 Reduce 中（这个过程可以保证相同的 Group By Key 被分布到同一个 Reduce 中），最后完

成最终的聚合操作。
</code></pre><p>  2.如何join？关于驱动表的选取，选用join key分布最均匀的表做为驱动表。做好列裁剪和filter操作，</p>
<pre><code>以达到两表做join的时候数据量相对变小的效果。
</code></pre><p>  3.使用mapjoin让小的维度表先进内存。在map端完成reduce。</p>
<p>  4.大表join大表时，把空值的key变成一个字符串加上随机数，把倾斜的数据随机分布到不同的reduce上，</p>
<pre><code>由于null值关联不上，处理后并不影响最终结果。
</code></pre><p>  5.count distinct时，将值为空的情况单独处理，如果是计算count distinct，可以不用处理，直接过滤，</p>
<pre><code>在最后结果中加1。如果还有其它计算，需要进行group by，可以先将值为空的记录单独处理，再和其他

结果进行union。
</code></pre><p>  6.采用sum() group by的方式来替换count(distinct )进行计算。</p>
<p>  7.在业务逻辑优化效果不大的情况下，有些时候是可以将倾斜的数据单独拿出来处理，最后union回去。</p>
<p>  8.对于控制产生的倾斜问题，解决方案1：为空的数据不参与关联；方案2：随机（rand()）赋予空值新的key。</p>
<pre><code>把空值的key变成一个字符串加上随机数，就能把倾斜的数据分到不同的reduce上，解决数据的倾斜问题。
</code></pre><p>  9.不同数据类型关联产生数据倾斜，默认的Hash操作会按int型的id来分配reduce，这样会导致所有的String</p>
<pre><code>类型数据分配到同一个reduce。
</code></pre><p>  10.使用 mapjoin 解决小表(记录数少)关联大表的数据倾斜问题，这个方法使用的频率非常高，但如果小表</p>
<pre><code> 很大，大到map join会出现bug或异常，这时就需要特别的处理。
</code></pre>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/">1</a><span class="page-number current">2</span><a class="page-number" href="/page/3/">3</a><a class="extend next" rel="next" href="/page/3/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Frone Xie</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">29</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">10</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">45</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/frone" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://blog.csdn.net/frone" target="_blank" title="CSDN">
                      
                        <i class="fa fa-fw fa-CSDN"></i>CSDN</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Frone Xie</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user">本站访客数</i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人数
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye">本站总访问量</i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>





  <script type="text/javascript">
    (function() {
      var hm = document.createElement("script");
      hm.src = "//tajs.qq.com/stats?sId=65946112";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
      <div id="needsharebutton-float">
        <span class="btn">
          <i class="fa fa-share-alt" aria-hidden="true"></i>
        </span>
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("ohqkXUU5txOlX3MjJPCrw7jG-gzGzoHsz", "bPQhLzRSEsTqdIKAGRcHLhyN");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  
  
  <link rel="stylesheet" href="/lib/needsharebutton/needsharebutton.css">

  
  
  <script src="/lib/needsharebutton/needsharebutton.js"></script>

  <script>
    
      pbOptions = {};
      
          pbOptions.iconStyle = "box";
      
          pbOptions.boxForm = "horizontal";
      
          pbOptions.position = "bottomCenter";
      
          pbOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-postbottom', pbOptions);
    
    
      flOptions = {};
      
          flOptions.iconStyle = "box";
      
          flOptions.boxForm = "horizontal";
      
          flOptions.position = "middleRight";
      
          flOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-float', flOptions);
    
  </script>

  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


  

  

  <script type="text/javascript" src="/js/src/love.js"></script><!-- hexo-inject:begin --><!-- hexo-inject:end -->
</body>
</html>
